<template>
	<view>
		<view class="bgimage" v-show="!loadingone">
			<view class="marshalling">
				<view class="signInIcon">
				</view>
				<view class="storeTitle">
					<view class="storeIcon">
					</view>
					<!-- 健康之家（百家湖店） -->
					{{result.storeName||''}}
				</view>
				<view class="signInFlex">
					<view class="signInView">
						<view class="title">
							<!-- 27次 -->
							{{result.count||''}}次
						</view>
						本月签到
					</view>
					<view class="signInView">
						<view class="title">
							<!-- 127次 -->
							{{result.sumCount||''}}次
						</view>
						累计签到
					</view>
				</view>
				<button class="Buttons" @tap="navhome()" type="default">进入小程序</button>
				<button type="default" class="jiaonangbutton"
					@tap="navurl('/pages/subpackage/home/major/major')"></button>
			</view>
		</view>
		<!-- 懒加载动画 -->
		<view class="loading-box">
			<u-loading :show="loadingone" color="#41ADBA" size="70"></u-loading>
		</view>
	</view>
</template>
<script>
import uLoading from "@/uview-ui/components/u-loading/u-loading.vue"
	export default {
		components: {
			uLoading
		},
		data() {
			return {
				storeId: '', //门店id
				phone: '', //用户手机号
				loadingone: true, //加载动画
				result: {
					storeName: '',
					count: '',
					sumCount: ''
				},
			}
		},
		onLoad(e) {
			console.log(e,'5555555555555')
            // 检测登录
			let storeId = uni.getStorageSync('storeId')
			if (e.storeId) { //有门店id  通过二维码编译
				this.storeId = e.storeId
				uni.setStorageSync('storeId', e.storeId)
			} else if (e.signIn == '1') { //登录后获取缓存
				this.storeId = storeId;
			}
			this.$basejs.globaltoken()
			// end
			this.phone = uni.getStorageSync(global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z').phone //静态手机号
			this.getSign()
			// this.loadingone = false
		},
		methods: {
			navurl(url) {
				uni.navigateTo({
					url: url
				})
			},
			navhome() {
				uni.setStorageSync('upPageurl','/pages/tab/home')
				uni.switchTab({
					url: '/pages/tab/home'
				});
			},
			// 签到
			getSign() {
				this.loadingone = true; //加载动画
				let _this = this;
				let fdata = {
					userId: uni.getStorageSync(global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z').userId,
					phone: this.phone,
					storeId: this.storeId,
				}
				this.$api.post(global.apiUrls.getSign, fdata)
					.then(res => {
						if (res.data.code == 1000) {
							_this.result = res.data.result
							if (res.data.result.isSign == 1) {
								uni.showToast({
									title: '今日已签到',
									icon: 'none',
									duration: 3000
								});
							}
						}else{
							_this.result = res.data.result
							uni.showToast({
								title: res.data.message,
								icon: 'none',
								duration: 3000
							});
						}
						_this.loadingone = false; //加载动画
					}).catch(err => {
						uni.showToast({
							title: '网络异常',
							icon: 'none',
							duration: 2000
						});
						setTimeout(() => {
							uni.switchTab({
								url: '/pages/tab/home'
							});
						}, 2000)
					})
			},
		}
	}
</script>
<style lang="scss">
	.bgimage {
		width: 100vw;
		min-height: 100vh;
		background: url('http://static.bsyjk.cn/bga/BA0ED50EA4A948D28C5999BF3BBA205B.png')no-repeat;
		background-size: 100% 100%;

		.marshalling {
			width: 574upx;
			height: 757upx;
			transform: scale(.9);
			position: relative;
			background: url('http://static.bsyjk.cn/singbg/1998DA8C767147DDADA9BEF0487EB5E7.png')no-repeat;
			background-size: 100% 100%;
			margin: 0 auto;
			top: 21vh;

			.Buttons {
				width: 400upx;
				height: 92upx;
				position: absolute;
				bottom: -143upx;
				background: url(http://static.bsyjk.cn/Button/F74824A019CD4092A7CF1663CB753826.png)no-repeat;
				background-size: 100% 100%;
				left: 50%;
				transform: translateX(-50%);
				font-size: 30upx;
				color: #fff;
				line-height: 92upx;
			}

			.jiaonangbutton {
				width: 700upx;
				height: 162upx;
				position: absolute;
				bottom: -370upx;
				left: 50%;
				transform: translateX(-50%);
				background: url(http://static.bsyjk.cn/jiaonangbutton/F31EFE5DFF8D4C3D9E85F70B5F97CC5B.png)no-repeat;
				background-size: 100% 100%;
			}

			.signInIcon {
				width: 409upx;
				height: 409upx;
				position: absolute;
				top: -200upx;
				left: 50%;
				transform: translateX(-50%);
				background: url(http://static.bsyjk.cn/signInIcon/BFE496C20C1A43E4A1EF9AD2B1659563.gif)no-repeat;
				background-size: 100% 100%;
			}

			.storeIcon {
				width: 44upx;
				height: 44upx;
				display: inline-block;
				background: url(http://static.bsyjk.cn/store/FB6BF6CADB6C4A3E86C2EC88C3836BE9.png)no-repeat;
				background-size: 100% 100%;
				transform: translateY(4px);
				margin-right: 10upx;
			}

			.storeTitle {
				width: 100%;
				position: absolute;
				top: 238upx;
				text-align: center;
				font-size: 36upx;
				color: #CA5E18;
			}

			.signInFlex {
				display: flex;
				position: absolute;
				width: 100%;
				top: 320upx;

				.signInView {
					width: 50%;
					text-align: center;

					.title {
						font-size: 44upx;
						color: #CA5E18;
					}

					font-size: 24upx;
					color: #FFE71A;
				}
			}
		}

	}
</style>
